﻿using System;

namespace DTM.Core.Utils
{
    /// <summary>
    /// Class <see cref="Validate"/> declare validation logic to check parameters.
    /// </summary>
    public static class Validate
	{
		/// <summary>
		/// Checks if object is not null, otherwise throw s new exception of T type
		/// </summary>
		/// <typeparam name="T">Exception type.</typeparam>
		/// <param name="obj">Object to validate.</param>
		/// <param name="message">Exception message.</param>
		public static void NotNull<T>(Object obj, string message) where T : Exception
		{
			if (obj == null)
			{
				var exception = (T)Activator.CreateInstance(typeof(T), message);
				throw exception;
			}
		}
	}
}
